home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 701-725 / 708 / intuisup / intuisup42.lha / Intuisup / source.lha / Editor / project.c < prev    next >
C/C++ Source or Header  |  1992-04-22  |  17KB  |  595 lines

  1. /* $Revision Header *** Header built automatically - do not edit! ***********
  2.  *
  3.  *    (C) Copyright 1991 by Torsten Jürgeleit
  4.  *
  5.  *    Name .....: project.c
  6.  *    Created ..: Sunday 22-Dec-91 21:22:52
  7.  *    Revision .: 1
  8.  *
  9.  *    Date        Author                 Comment
  10.  *    =========   ====================   ====================
  11.  *    22-Apr-91   Torsten Jürgeleit      now for SELECTUP check if
  12.  *                                         SELECTDOWN before
  13.  *    22-Dec-91   Torsten Jürgeleit      Created this file!
  14.  *
  15.  ****************************************************************************
  16.  *
  17.  *    Project part
  18.  *
  19.  * $Revision Header ********************************************************/
  20.  
  21.     /* Includes */
  22.  
  23. #include "includes.h"
  24. #include "defines.h"
  25. #include "imports.h"
  26. #include "protos.h"
  27.  
  28.     /* Defines */
  29.  
  30. #define MOUSE_BUTTON_SELECT        (1 << 0)
  31. #define MOUSE_BUTTON_MENU        (1 << 1)
  32. #define MOUSE_BUTTON_RUBBER_BAND    (1 << 2)
  33.  
  34. #define PROJECT_TITLE_REFRESH_DELAY    500000   /* µs */
  35.  
  36.     /* Perform project action */
  37.  
  38.    SHORT
  39. perform_project_action(VOID)
  40. {
  41.    struct Box           *box = ¤t_box;
  42.    struct MsgPort       *up = pwin->UserPort;
  43.    struct IntuiMessage  *msg;
  44.    ULONG seconds, micros, last_seconds, last_micros;
  45.    SHORT status = EDITOR_STATUS_NORMAL;
  46.  
  47.    while (msg = IGetMsg(up)) {
  48.       struct Template  *tp;
  49.       SHORT mouse_x, mouse_y, snap_x, snap_y;
  50.  
  51.       /* Get mouse position */
  52.       mouse_x = msg->MouseX;
  53.       mouse_y = msg->MouseY;
  54.       snap_x  = (mouse_x + (snap_offset >> 1)) / snap_offset * snap_offset;
  55.       snap_y  = (mouse_y + (snap_offset >> 1)) / snap_offset * snap_offset;
  56.       switch (msg->Class) {
  57.      case MOUSEBUTTONS :
  58.         switch (msg->Code) {
  59.                  case SELECTDOWN :
  60.           clear_template_info();
  61.           switch (editor_mode) {
  62.              case EDITOR_MODE_CREATE :
  63.             box->bo_X1    = box->bo_X2 = snap_x;
  64.             box->bo_Y1    = box->bo_Y2 = snap_y;
  65.             mouse_button |= MOUSE_BUTTON_RUBBER_BAND;
  66.             draw_box(pwin, box);
  67.             break;
  68.  
  69.              case EDITOR_MODE_MODIFY :
  70.             if (select_template_by_pos(mouse_x, mouse_y)) {
  71.                draw_box(pwin, box);
  72.                last_snap_x   = snap_x;
  73.                last_snap_y   = snap_y;
  74.                modify_mode   = get_modify_mode(mouse_x, mouse_y);
  75.                mouse_button |= MOUSE_BUTTON_RUBBER_BAND;
  76.                print_template_info();
  77.             }
  78.             break;
  79.  
  80.              case EDITOR_MODE_CLONE :
  81.             if (select_template_by_pos(mouse_x, mouse_y)) {
  82.                draw_box(pwin, box);
  83.                last_snap_x   = snap_x;
  84.                last_snap_y   = snap_y;
  85.                mouse_button |= MOUSE_BUTTON_RUBBER_BAND;
  86.                print_template_info();
  87.             }
  88.             break;
  89.  
  90.              case EDITOR_MODE_DELETE :
  91.              case EDITOR_MODE_EDIT :
  92.             if (select_template_by_pos(mouse_x, mouse_y)) {
  93.                mouse_button |= MOUSE_BUTTON_RUBBER_BAND;
  94.                print_template_info();
  95.             }
  96.             break;
  97.           }
  98.           mouse_button |= MOUSE_BUTTON_SELECT;
  99.           if (editor_mode != EDITOR_MODE_USE) {
  100.              print_project_window_title();
  101.           }
  102.           break;
  103.  
  104.            case SELECTUP :
  105.           if (mouse_button & MOUSE_BUTTON_SELECT) {
  106.              tp = selected_template;
  107.              switch (editor_mode) {
  108.             case EDITOR_MODE_CREATE :
  109.                if (mouse_button & MOUSE_BUTTON_RUBBER_BAND) {
  110.                   draw_box(pwin, box);
  111.                   box->bo_X2 = snap_x;
  112.                   box->bo_Y2 = snap_y;
  113.                   fix_template_bounds();
  114.                   end_rubber_banding();
  115.                }
  116.                break;
  117.  
  118.             case EDITOR_MODE_MODIFY :
  119.                if (mouse_button & MOUSE_BUTTON_RUBBER_BAND) {
  120.                   draw_box(pwin, box);
  121.                   clear_template_info();
  122.                   if (tp->tp_Flags & TEMPLATE_FLAG_MODIFIED) {
  123.                  tp->tp_Flags &= ~TEMPLATE_FLAG_MODIFIED;
  124.                  if (mouse_x < 0 || mouse_x > pwin->Width ||
  125.                                   mouse_y < 0 ||
  126.                            mouse_y > pwin->Height) {
  127.                     DisplayBeep((LONG)NULL);
  128.                  } else {
  129.                     if (modify_mode == MODIFY_MODE_MOVE) {
  130.                        box->bo_X1 += snap_x - last_snap_x;
  131.                        box->bo_Y1 += snap_y - last_snap_y;
  132.                        box->bo_X2 += snap_x - last_snap_x;
  133.                        box->bo_Y2 += snap_y - last_snap_y;
  134.                     } else {
  135.                        box->bo_X2 += snap_x - last_snap_x;
  136.                        box->bo_Y2 += snap_y - last_snap_y;
  137.                     }
  138.                     fix_template_bounds();
  139.                     end_rubber_banding();
  140.                  }
  141.                   }
  142.                }
  143.                break;
  144.  
  145.             case EDITOR_MODE_CLONE :
  146.                if (mouse_button & MOUSE_BUTTON_RUBBER_BAND) {
  147.                   draw_box(pwin, box);
  148.                   clear_template_info();
  149.                   if (mouse_x < 0 || mouse_x > pwin->Width ||
  150.                     mouse_y < 0 || mouse_y > pwin->Height) {
  151.                  DisplayBeep((LONG)NULL);
  152.                   } else {
  153.                  box->bo_X1 += snap_x - last_snap_x;
  154.                  box->bo_Y1 += snap_y - last_snap_y;
  155.                  box->bo_X2 += snap_x - last_snap_x;
  156.                  box->bo_Y2 += snap_y - last_snap_y;
  157.                  fix_template_bounds();
  158.                  end_rubber_banding();
  159.                   }
  160.                   tp->tp_Flags &= ~TEMPLATE_FLAG_MODIFIED;
  161.                }
  162.                break;
  163.  
  164.             case EDITOR_MODE_DELETE :
  165.                if (mouse_button & MOUSE_BUTTON_RUBBER_BAND) {
  166.                   clear_template_info();
  167.                   delete_template(selected_template);
  168.                }
  169.                break;
  170.  
  171.             case EDITOR_MODE_EDIT :
  172.                if (mouse_button & MOUSE_BUTTON_RUBBER_BAND) {
  173.                   info_template  = NULL;
  174.                   info_displayed = FALSE;
  175.                   status         = EDITOR_STATUS_EDIT;
  176.                }
  177.                break;
  178.              }
  179.              mouse_button &= ~(MOUSE_BUTTON_SELECT |
  180.                           MOUSE_BUTTON_RUBBER_BAND);
  181.              if (editor_mode != EDITOR_MODE_USE) {
  182.             print_project_window_title();
  183.             ActivateWindow(ewin);
  184.              }
  185.           }
  186.           break;
  187.  
  188.            case MENUDOWN :
  189.           mouse_button |= MOUSE_BUTTON_MENU;
  190.           break;
  191.  
  192.            case MENUUP :
  193.           mouse_button &= ~MOUSE_BUTTON_MENU;
  194.           ActivateWindow(ewin);
  195.           break;
  196.         }
  197.         break;
  198.  
  199.      case MOUSEMOVE :
  200.         if (mouse_button & MOUSE_BUTTON_SELECT) {
  201.  
  202.            /* Save time for project title refresh delay while rubberbanding */
  203.            tp           = selected_template;
  204.            last_seconds = seconds;
  205.            last_micros  = micros;
  206.            seconds      = msg->Seconds;
  207.            micros       = msg->Micros;
  208.            switch (editor_mode) {
  209.               case EDITOR_MODE_CREATE :
  210.              if (mouse_button & MOUSE_BUTTON_RUBBER_BAND) {
  211.             draw_box(pwin, box);
  212.             box->bo_X2 = snap_x;
  213.             box->bo_Y2 = snap_y;
  214.             last_snap_x = snap_x;
  215.             last_snap_y = snap_y;
  216.             draw_box(pwin, box);
  217.             if (seconds != last_seconds || (micros -
  218.                    last_micros) > PROJECT_TITLE_REFRESH_DELAY) {
  219.                print_project_window_title();
  220.             }
  221.              }
  222.              break;
  223.  
  224.           case EDITOR_MODE_MODIFY :
  225.              if (mouse_button & MOUSE_BUTTON_RUBBER_BAND) {
  226.             draw_box(pwin, box);
  227.             if (modify_mode == MODIFY_MODE_MOVE) {
  228.                box->bo_X1 += snap_x - last_snap_x;
  229.                box->bo_Y1 += snap_y - last_snap_y;
  230.                box->bo_X2 += snap_x - last_snap_x;
  231.                box->bo_Y2 += snap_y - last_snap_y;
  232.             } else {
  233.                box->bo_X2 += snap_x - last_snap_x;
  234.                box->bo_Y2 += snap_y - last_snap_y;
  235.             }
  236.             last_snap_x = snap_x;
  237.             last_snap_y = snap_y;
  238.             draw_box(pwin, box);
  239.             if (seconds != last_seconds || (micros -
  240.                    last_micros) > PROJECT_TITLE_REFRESH_DELAY) {
  241.                print_project_window_title();
  242.             }
  243.             tp->tp_Flags |= TEMPLATE_FLAG_MODIFIED;
  244.              }
  245.              break;
  246.  
  247.           case EDITOR_MODE_CLONE :
  248.              if (mouse_button & MOUSE_BUTTON_RUBBER_BAND) {
  249.             draw_box(pwin, box);
  250.             box->bo_X1 += snap_x - last_snap_x;
  251.             box->bo_Y1 += snap_y - last_snap_y;
  252.             box->bo_X2 += snap_x - last_snap_x;
  253.             box->bo_Y2 += snap_y - last_snap_y;
  254.             last_snap_x = snap_x;
  255.             last_snap_y = snap_y;
  256.             draw_box(pwin, box);
  257.             if (seconds != last_seconds || (micros -
  258.                    last_micros) > PROJECT_TITLE_REFRESH_DELAY) {
  259.                print_project_window_title();
  260.             }
  261.             tp->tp_Flags |= TEMPLATE_FLAG_MODIFIED;
  262.              }
  263.              break;
  264.  
  265.           case EDITOR_MODE_DELETE :
  266.           case EDITOR_MODE_EDIT :
  267.              if (tp) {
  268.  
  269.             /* Check if mouse points to selected template */
  270.             if (find_template_by_pos(mouse_x, mouse_y) == tp) {
  271.                if (!(mouse_button & MOUSE_BUTTON_RUBBER_BAND)) {
  272.                   mouse_button |= MOUSE_BUTTON_RUBBER_BAND;
  273.                   print_template_info();
  274.                   print_project_window_title();
  275.                }
  276.             } else {
  277.                if (mouse_button & MOUSE_BUTTON_RUBBER_BAND) {
  278.                   mouse_button &= ~MOUSE_BUTTON_RUBBER_BAND;
  279.                   clear_template_info();
  280.                   print_project_window_title();
  281.                }
  282.             }
  283.              }
  284.              break;
  285.            }
  286.         }
  287.         break;
  288.  
  289.      case NEWSIZE :
  290.         refresh_all_templates();
  291.         ActivateWindow(ewin);
  292.         template_list.tl_Flags |= TEMPLATE_LIST_FLAG_CHANGED;
  293.         break;
  294.       }
  295.       IReplyMsg(msg);
  296.    }
  297.    return(status);
  298. }
  299.     /* End rubber banding */
  300.  
  301.    STATIC VOID
  302. end_rubber_banding(VOID)
  303. {
  304.    struct Box  *box = ¤t_box;
  305.    USHORT type, min_width, min_height, width = box->bo_X2 - box->bo_X1 + 1,
  306.           height = box->bo_Y2 - box->bo_Y1 + 1;
  307.  
  308.    /* First get current template type */
  309.    if (editor_mode == EDITOR_MODE_CREATE) {
  310.       type = template_type;
  311.    } else {
  312.       type = selected_template->tp_Type;
  313.    }
  314.  
  315.    /* Now calc minimal dimension required for template */
  316.    switch (type) {
  317.       case TEMPLATE_TYPE_SLIDER :
  318.       case TEMPLATE_TYPE_SCROLLER :
  319.       case TEMPLATE_TYPE_PALETTE :
  320.      if (width / 2 > height) {
  321.         min_width  = min_dimension[type].dim_Width;
  322.         min_height = min_dimension[type].dim_Height;
  323.      } else {
  324.         min_width  = min_dimension[type].dim_Height * 2;
  325.         min_height = min_dimension[type].dim_Width / 2;
  326.      }
  327.      break;
  328.  
  329.       default :
  330.      min_width  = min_dimension[type].dim_Width;
  331.      min_height = min_dimension[type].dim_Height;
  332.      break;
  333.    }
  334.  
  335.    /* Check template dimension is greater than minimal */
  336.    if (width < min_width || height < min_height) {
  337.       DisplayBeep((LONG)NULL);
  338.    } else {
  339.       struct TemplateList  *tl = &template_list;
  340.       struct Template      *tp;
  341.       struct BorderData    *bd;
  342.       struct TextData      *td;
  343.       struct GadgetData    *gd;
  344.  
  345.       switch (editor_mode) {
  346.      case EDITOR_MODE_CREATE :
  347.         tp = create_template(tl);
  348.         display_template(tp);
  349.         break;
  350.  
  351.      case EDITOR_MODE_MODIFY :
  352.         tp = selected_template;
  353.         CopyMem((BYTE *)box, (BYTE *)
  354.                      &tp->tp_Box, (LONG)sizeof(struct Box));
  355.         /* Change template dimension */
  356.         switch (type) {
  357.            case TEMPLATE_TYPE_BORDER :
  358.           bd              = &tp->tp_Data.tp_BorderData;
  359.           bd->bd_LeftEdge = box->bo_X1;
  360.           bd->bd_TopEdge  = box->bo_Y1;
  361.           bd->bd_Width    = width;
  362.           bd->bd_Height   = height;
  363.           break;
  364.  
  365.            case TEMPLATE_TYPE_TEXT :
  366.           td              = &tp->tp_Data.tp_TextData;
  367.           td->td_LeftEdge = box->bo_X1;
  368.           td->td_TopEdge  = box->bo_Y1;
  369.  
  370.           /* Calc size of text for template box */
  371.           box        = &tp->tp_Box;
  372.           box->bo_X2 = box->bo_X1 + IPrintText(pri, pwin, td->td_Text,
  373.                    td->td_LeftEdge, td->td_TopEdge, td->td_Type,
  374.                   TEXT_DATA_FLAG_NO_PRINT, td->td_TextAttr) - 1;
  375.           box->bo_Y2 = box->bo_Y1 + td->td_TextAttr->ta_YSize - 1;
  376.           break;
  377.  
  378.            default :
  379.           gd              = &tp->tp_Data.tp_GadgetData;
  380.           gd->gd_LeftEdge = box->bo_X1;
  381.           gd->gd_TopEdge  = box->bo_Y1;
  382.           gd->gd_Width    = width;
  383.           gd->gd_Height   = height;
  384.           switch (gd->gd_Type) {
  385.              case GADGET_DATA_TYPE_SLIDER :
  386.             if (width / 2 < height) {
  387.                gd->gd_Flags |= GADGET_DATA_FLAG_ORIENTATION_VERT;
  388.             } else {
  389.                gd->gd_Flags &= ~GADGET_DATA_FLAG_ORIENTATION_VERT;
  390.             }
  391.             break;
  392.  
  393.              case GADGET_DATA_TYPE_SCROLLER :
  394.             if (width / 2 < height) {
  395.                gd->gd_Flags |= GADGET_DATA_FLAG_ORIENTATION_VERT;
  396.             } else {
  397.                gd->gd_Flags &= ~GADGET_DATA_FLAG_ORIENTATION_VERT;
  398.             }
  399.             break;
  400.  
  401.              case GADGET_DATA_TYPE_PALETTE :
  402.             if (width / 2 < height) {
  403.                gd->gd_Flags |= GADGET_DATA_FLAG_PALETTE_INDICATOR_TOP;
  404.             } else {
  405.                gd->gd_Flags &= ~GADGET_DATA_FLAG_PALETTE_INDICATOR_TOP;
  406.             }
  407.             gd->gd_SpecialData.gd_PaletteData.gd_PaletteDepth       = 2;
  408.             gd->gd_SpecialData.gd_PaletteData.gd_PaletteColorOffset = 0;
  409.             gd->gd_SpecialData.gd_PaletteData.gd_PaletteActiveColor = 2;
  410.             break;
  411.           }
  412.           break;
  413.         }
  414.         refresh_all_templates();
  415.         break;
  416.  
  417.      case EDITOR_MODE_CLONE :
  418.         tp = clone_template(tl, selected_template, FALSE);
  419.         display_template(tp);
  420.         break;
  421.       }
  422.       template_list.tl_Flags |= TEMPLATE_LIST_FLAG_CHANGED;
  423.    }
  424. }
  425.     /* Print project window title */
  426.  
  427.    VOID
  428. print_project_window_title(VOID)
  429. {
  430.    struct Box  *box = ¤t_box;
  431.    BYTE   *title = &project_window_title[0];
  432.    USHORT width, height;
  433.  
  434.    if (box->bo_X2 > box->bo_X1) {
  435.       width = box->bo_X2 - box->bo_X1 + 1;
  436.    } else {
  437.       width = box->bo_X1 - box->bo_X2 + 1;
  438.    }
  439.    if (box->bo_Y2 > box->bo_Y1) {
  440.       height = box->bo_Y2 - box->bo_Y1 + 1;
  441.    } else {
  442.       height = box->bo_Y1 - box->bo_Y2 + 1;
  443.    }
  444.    switch (editor_mode) {
  445.       case EDITOR_MODE_CREATE :
  446.      if (mouse_button & MOUSE_BUTTON_RUBBER_BAND) {
  447.         SPrintf(title, " Left=%d Top=%d Width=%d Height=%d ", 
  448.                      box->bo_X1, box->bo_Y1, width, height);
  449.      } else {
  450.         SPrintf(title, " Create %s Template ",
  451.                    template_type_text_array[template_type]);
  452.      }
  453.      break;
  454.  
  455.       case EDITOR_MODE_MODIFY :
  456.      if (mouse_button & MOUSE_BUTTON_RUBBER_BAND) {
  457.         SPrintf(title, " Left=%d Top=%d Width=%d Height=%d ", 
  458.                      box->bo_X1, box->bo_Y1, width, height);
  459.      } else {
  460.         strcpy(title, " Modify Template ");
  461.      }
  462.      break;
  463.  
  464.       case EDITOR_MODE_DELETE :
  465.      if (mouse_button & MOUSE_BUTTON_RUBBER_BAND) {
  466.         SPrintf(title, " Left=%d Top=%d Width=%d Height=%d ", 
  467.                      box->bo_X1, box->bo_Y1, width, height);
  468.      } else {
  469.         strcpy(title, " Delete Template ");
  470.      }
  471.      break;
  472.  
  473.       case EDITOR_MODE_EDIT :
  474.      strcpy(title, " Edit Template ");
  475.      break;
  476.  
  477.       case EDITOR_MODE_USE :
  478.      strcpy(title, " Use Templates ");
  479.      break;
  480.    }
  481.    SetWindowTitles(pwin, title, (LONG)NULL);
  482. }
  483.     /* Start a new project */
  484.  
  485.    SHORT
  486. new_project(struct TemplateList  *tl, USHORT new_flags)
  487. {
  488.    SHORT status;
  489.  
  490.    /* Free all templates */
  491.    free_template_list(tl);
  492.    ISetGadgetAttributes(egl, EDITOR_GADGET_TEMPLATES, 0L, 0L,
  493.            USE_CURRENT_VALUE, USE_CURRENT_VALUE, &tl->tl_Templates);
  494.    clear_template_info();
  495.  
  496.    /* Use default project name? */
  497.    if (new_flags & TEMPLATE_LIST_FLAG_DEFAULT_WINDOW) {
  498.       change_project_name(tl, DEFAULT_PROJECT_NAME, -1);
  499.       strcpy(project_file_requester->fr_File, DEFAULT_PROJECT_FILE_NAME);
  500.    }
  501.  
  502.    /* Close old project window and open new one */
  503.    if ((status = new_project_window(tl, new_flags)) == EDITOR_STATUS_NORMAL) {
  504.       print_project_window_title();
  505.    }
  506.    return(show_error(status));
  507. }
  508.     /* Close old project window and open new one */
  509.  
  510.    SHORT
  511. new_project_window(struct TemplateList  *tl, USHORT new_flags)
  512. {
  513.    struct NewWindow  *nwin = &project_new_window;
  514.    USHORT flags;
  515.    SHORT  status;
  516.  
  517.    /* Use default template list data? */
  518.    if (new_flags & TEMPLATE_LIST_FLAG_DEFAULT_WINDOW) {
  519.       nwin->LeftEdge = 0;
  520.       nwin->TopEdge  = ewin->Height + 1;
  521.       nwin->Width    = wb_screen.Width;
  522.       nwin->Height   = wb_screen.Height - nwin->TopEdge;
  523.       new_flags      = tl->tl_Flags = DEFAULT_TEMPLATE_LIST_FLAGS;
  524.    }
  525.  
  526.    /* Change render info */
  527.    if (pri) {
  528.       IFreeRenderInfo(pri);
  529.    }
  530.    flags = PROJECT_RENDER_INFO_FLAGS |
  531.                  (new_flags & TEMPLATE_LIST_FLAG_BACK_FILL ?
  532.                        RENDER_INFO_FLAG_BACK_FILL : 0) |
  533.                    (new_flags & TEMPLATE_LIST_FLAG_AVAIL_FONTS ?
  534.                       RENDER_INFO_FLAG_AVAIL_FONTS : 0);
  535.    if (!(pri = IGetRenderInfo((struct Screen *)NULL, flags))) {
  536.       status = EDITOR_ERROR_OUT_OF_MEM;
  537.    } else {
  538.  
  539.       /* Change new window structure */
  540.       if (new_flags & TEMPLATE_LIST_FLAG_RESIZING) {
  541.      nwin->Flags |= WINDOWSIZING;
  542.       } else {
  543.      nwin->Flags &= ~WINDOWSIZING;
  544.       }
  545.       if (new_flags & TEMPLATE_LIST_FLAG_RENDER_COLORS) {
  546.      flags = (PROJECT_OPEN_WINDOW_FLAGS | OPEN_WINDOW_FLAG_RENDER_PENS);
  547.       } else {
  548.      nwin->DetailPen = PROJECT_WINDOW_DETAIL_PEN;
  549.      nwin->BlockPen  = PROJECT_WINDOW_BLOCK_PEN;
  550.      flags           = PROJECT_OPEN_WINDOW_FLAGS;
  551.       }
  552.  
  553.       /* Open new project window */
  554.       if (pwin) {
  555.      ICloseWindow(pwin, FALSE);
  556.       }
  557.       if (!(pwin = IOpenWindow(pri, nwin, flags))) {
  558.      status = EDITOR_ERROR_NO_WINDOW;
  559.       } else {
  560.      print_project_window_title();
  561.      status = EDITOR_STATUS_NORMAL;
  562.       }
  563.    }
  564.    return(show_error(status));
  565. }
  566.     /* Clear project window */
  567.  
  568.    VOID
  569. clear_project_window(USHORT flags)
  570. {
  571.    SetRast(pwin->RPort, 0L);
  572.    RefreshWindowFrame(pwin);
  573.    if (flags & TEMPLATE_LIST_FLAG_BACK_FILL) {
  574.       IClearWindow(pri, pwin, 0, 0, -1, -1, 0);
  575.    }
  576. }
  577.     /* Change project name and display it as window title */
  578.  
  579.    VOID
  580. change_project_name(struct TemplateList  *tl, BYTE *new_name, SHORT len)
  581. {
  582.    BYTE *name = &tl->tl_ProjectName[0], *title = &editor_window_title[0];
  583.  
  584.    if (len < 0) {
  585.       len = strlen(new_name);
  586.    }
  587.    if (len > MAX_PROJECT_NAME_LEN) {
  588.       len = MAX_PROJECT_NAME_LEN;
  589.    }
  590.    strncpy(name, new_name, (size_t)len);
  591.    *(name + len) = '\0';
  592.    SPrintf(title, " %s ", name);
  593.    SetWindowTitles(ewin, title, (BYTE *)-1L);
  594. }
  595.